﻿
using FriendStar.Application.WareHouse;
using FriendStar.Code;
using System;
using System.Collections.Generic;
using System.Web.Mvc;

namespace FriendStar.Web.Areas.WareHouse.Controllers
{

    public class ContainerController : Controller
    {
        //
        // GET: /WareHouse/Container/
        private ContainerApp app = new ContainerApp();

        private string useUnit = Configs.GetValue("UseUnit");

        private string factoryFlag = Configs.GetValue("FactoryFlag");

        private string curUser = OperatorProvider.Provider.GetCurrent().UserName;

        private string MYDESC = "台账日期容器";

        public ActionResult Index()
        {
            return View();
        }
        public ActionResult ContainerPurchaseEnther()
        {
            ContainerApp containerApp = new ContainerApp();

            ViewData["defaultDate"] = containerApp.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            return View();
        }
        public ActionResult ContainerPurchaseInstockEdit(string FDocuNO)
        {
            string CDESC = "容器采购";

            if (null != FDocuNO)
            {
                ViewData["FDocuNO"] = FDocuNO;
            }
            else
            {
                ViewData["FDocuNO"] = app.GetDocumentNum(useUnit, factoryFlag, CDESC, curUser, "临时");
            }

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["defaultDate"] = app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            return View();
        }
        public ActionResult ContainerStubbsInstockEdit(string FDocuNO)
        {
            string CDESC = "调拨入库";

            if (null != FDocuNO)
            {
                ViewData["FDocuNO"] = FDocuNO;
            }
            else
            {
                ViewData["FDocuNO"] = app.GetDocumentNum(useUnit, factoryFlag, CDESC, curUser, "临时");
            }

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["defaultDate"] = app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            return View();
        }
        public ActionResult ContainerTurnOverEntherEdit(string FDocuNO)
        {
            string CDESC = "容器入库";

            if (null != FDocuNO)
            {
                ViewData["FDocuNO"] = FDocuNO;
            }
            else
            {
                ViewData["FDocuNO"] = app.GetDocumentNum(useUnit, factoryFlag, CDESC, curUser, "临时");
            }

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["defaultDate"] = app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            return View();
        }
        public ActionResult ContainerOutstockEdit(string FDocuNO)
        {
            string CDESC = "容器出库";

            if (null != FDocuNO)
            {
                ViewData["FDocuNO"] = FDocuNO;
            }
            else
            {
                ViewData["FDocuNO"] = app.GetDocumentNum(useUnit, factoryFlag, CDESC, curUser, "临时");
            }

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["defaultDate"] = app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            return View();
        }
        public ActionResult ContainerStubbsOutstockEdit(string FDocuNO)
        {
            string CDESC = "调拨出库";

            if (null != FDocuNO)
            {
                ViewData["FDocuNO"] = FDocuNO;
            }
            else
            {
                ViewData["FDocuNO"] = app.GetDocumentNum(useUnit, factoryFlag, CDESC, curUser, "临时");
            }

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["defaultDate"] = app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            return View();
        }
        public ActionResult ContainerRepairEdit(string FDocuNO)
        {
            string CDESC = "容器返修";

            if (null != FDocuNO)
            {
                ViewData["FDocuNO"] = FDocuNO;
            }
            else
            {
                ViewData["FDocuNO"] = app.GetDocumentNum(useUnit, factoryFlag, CDESC, curUser, "临时");
            }

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["defaultDate"] = app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            return View();
        }
        public ActionResult ContainerScrapEdit(string FDocuNO)
        {
            string CDESC = "容器报损";

            if (null != FDocuNO)
            {
                ViewData["FDocuNO"] = FDocuNO;
            }
            else
            {
                ViewData["FDocuNO"] = app.GetDocumentNum(useUnit, factoryFlag, CDESC, curUser, "临时");
            }

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["defaultDate"] = app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            return View();
        }
        public ActionResult ContainerTakeInventoryEdit(string FDocuNO)
        {
            string CDESC = "容器盘存";

            if (null != FDocuNO)
            {
                ViewData["FDocuNO"] = FDocuNO;
            }
            else
            {
                ViewData["FDocuNO"] = app.GetDocumentNum(useUnit, factoryFlag, CDESC, curUser, "临时");
            }

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["defaultDate"] = app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            return View();
        }

        public ActionResult ContainerPurchaseInstockEditAdd(string FDocuNO)
        {
            return View();
        }
        public ActionResult ContainerTurnOverInstockEditAdd(string FDocuNO)
        {
            return View();
        }
        public ActionResult ContainerStubbsInstockEditAdd(string FDocuNO)
        {
            return View();
        }
        public ActionResult ContainerOutstockEditAdd(string FDocuNO)
        {
            return View();
        }
        public ActionResult ContainerStubbsOutstockEditAdd(string FDocuNO)
        {
            return View();
        }
        public ActionResult ContainerRepairEditAdd(string FDocuNO)
        {
            return View();
        }
        public ActionResult ContainerScrapEditAdd(string FDocuNO)
        {
            return View();
        }
        public ActionResult ContainerTakeInventoryEditAdd(string FDocuNO)
        {
            return View();
        }
        public ActionResult ContainerPurchaseEntherInput()
        {
            return View();
        }
        public ActionResult ContainerPurchaseEntherCheck()
        {
            return View();
        }
        public ActionResult ContainerPurchaseEntherModi()
        {
            return View();
        }
        public ActionResult ContainerLedgerDetails(string param, string FAccountDate)
        {
            ViewData["jsonData"] = param;

            ViewData["defaultDate"] = FAccountDate;

            ViewData["isDefaultDate"] = FAccountDate == app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            return View();
        }
        public ActionResult ContainerLedgerStatistics(string param, string FAccountDate)
        {
            ViewData["jsonData"] = param;

            ViewData["defaultDate"] = FAccountDate;

            ViewData["isDefaultDate"] = FAccountDate == app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            return View();
        }
        public ActionResult ContainerTurnOverEnther()
        {
            ContainerApp containerApp = new ContainerApp();

            ViewData["defaultDate"] = containerApp.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            return View();
        }
        public ActionResult ContainerOut()
        {
            ContainerApp containerApp = new ContainerApp();

            ViewData["defaultDate"] = containerApp.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            return View();
        }
        public ActionResult ContainerScrap()
        {
            ContainerApp containerApp = new ContainerApp();

            ViewData["defaultDate"] = containerApp.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");
            return View();
        }
        public ActionResult ContainerRepair()
        {
            ContainerApp containerApp = new ContainerApp();

            ViewData["defaultDate"] = containerApp.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            return View();
        }
        public ActionResult ContainerStaticstist()
        {
            ViewData["LedgerDate"] = app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            return View();
        }
        public ActionResult ContainerLedger()
        {
            ViewData["LedgerDate"] = app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            return View();
        }
        public ActionResult ContainerReport()
        {
            ViewData["LedgerDate"] = app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy-MM-dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            return View();
        }
        public ActionResult ContainerReportDetails(string FAccountDate, string FHappenCompanyNO, string FContainerNO, string FContainerName, string FHappenCompanyNOName)
        {
            ViewData["LedgerDate"] = app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy-MM-dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            ViewData["FHappenCompanyNO"] = FHappenCompanyNO;

            ViewData["FContainerNO"] = FContainerNO;

            ViewData["FContainerName"] = FContainerName;

            ViewData["FHappenCompanyNOName"] = FHappenCompanyNOName;

            ViewData["FAccountDate"] = FAccountDate;

            return View();
        }



        public ActionResult ContainerStubbsInStock()
        {
            ContainerApp containerApp = new ContainerApp();

            ViewData["defaultDate"] = containerApp.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            return View();
        }

        public ActionResult ContainerPurchaseEntherModify()
        {
            return View();
        }


        public ActionResult ContainerStubbsOutStock()
        {
            ContainerApp containerApp = new ContainerApp();

            ViewData["defaultDate"] = containerApp.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            return View();
        }
        public ActionResult ContainerTakeInventory()
        {
            ContainerApp containerApp = new ContainerApp();

            ViewData["defaultDate"] = containerApp.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            ViewData["curUserName"] = OperatorProvider.Provider.GetCurrent().UserName;

            ViewData["curUnit"] = useUnit;

            ViewData["curDate"] = DateTime.Now.ToString("yyyy/MM/dd");

            ViewData["curTime"] = DateTime.Now.ToString("HH:mm:ss");

            return View();
        }

        /// <summary>
        /// GET: /WareHouse/Container/Details/5
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Details(int id)
        {


            return View();
        }

        //
        // GET: /WareHouse/Container/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /WareHouse/Container/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /WareHouse/Container/Edit/5

        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /WareHouse/Container/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /WareHouse/Container/Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /WareHouse/Container/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        public ActionResult GetSupplierJson(string o)
        {
            bool isOut = "1".Equals(o);

            var data = app.GetSupplierInformations(useUnit, isOut);

            return Content(data.ToJson());
        }
        public ActionResult GetHappenCompanyInfo()
        {
            var data = app.GetHappenCompanyInfo();

            return Content(data.ToJson());
        }

        public ActionResult GetDocuType(string FTypeNO)
        {
            var data = app.GetDocuType(FTypeNO, useUnit);

            return Content(data.ToJson());
        }

        public ActionResult GetContainerNOList()
        {
            var data = app.GetContainerNOList(useUnit);

            return Content(data.ToJson());
        }
        public ActionResult GetContainerNOOutList()
        {
            var data = app.GetContainerNOOutList(useUnit);

            return Content(data.ToJson());
        }
        public ActionResult GetFStoreNOList()
        {
            var data = app.GetFStoreNOList(useUnit);

            return Content(data.ToJson());
        }
        public ActionResult GetFStoreSetNO(string FStoreNO)
        {
            var data = app.GetFStoreSetNOList(useUnit, FStoreNO);

            return Content(data.ToJson());
        }
        public ActionResult GetContainerTypeNO()
        {
            var data = app.GetContainerTypeNO(useUnit);

            return Content(data.ToJson());
        }

        public ActionResult GetFlowReceiveAndDispatchExchange(Pagination pagination, string FHappenCompanyNO, string FHappenCompanyType)
        {
            var data = new
            {
                rows = app.GetFlowReceiveAndDispatchExchange(pagination, FHappenCompanyNO, FHappenCompanyType, useUnit),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        public ActionResult GetFlowReceiveAndDispatchStatistics(Pagination pagination, string FAccountDate, string FContainerNO)
        {
            var data = new
            {
                rows = app.GetFlowReceiveAndDispatchStatistics(pagination, FAccountDate, FContainerNO, useUnit),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        public ActionResult GetMoveToReceiveAndDispatchStatistics(Pagination pagination, string FAccountDate, string FHappenCompanyNO, string FContainerNO)
        {
            var data = new
            {
                rows = app.GetMoveToReceiveAndDispatchStatistics(pagination, FAccountDate, FHappenCompanyNO, FContainerNO, useUnit),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        public ActionResult GetMoveToReceiveAndDispatchStatisticsDetails(Pagination pagination,string FAccountDate, string FHappenCompanyNO, string FContainerNO)
        {
            var data = new
            {
                rows = app.GetMoveToReceiveAndDispatchStatisticsDetails(pagination, FAccountDate, FHappenCompanyNO, FContainerNO, useUnit),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }


        public ActionResult GetPurchaseInstocks(Pagination pagination, string FDocuNO, string FHappenComNO, string FContainerNO, string FCurDate, string Fcredence, string FAccountDate, bool isDefaultDate, bool isArchive)
        {
            string FDocuTypeNo = "RG";

            var data = new
            {
                rows = app.GetPurchaseInstocks(pagination, FDocuNO, FHappenComNO, FContainerNO, FCurDate, Fcredence, FAccountDate, useUnit, isDefaultDate, isArchive, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        public ActionResult GetTurnOverInstocks(Pagination pagination, string FDocuNO, string FHappenComNO, string FContainerNO, string FCurDate, string Fcredence, string FAccountDate, bool isDefaultDate, bool isArchive)
        {
            string FDocuTypeNo = "RR";

            var data = new
            {
                rows = app.GetPurchaseInstocks(pagination, FDocuNO, FHappenComNO, FContainerNO, FCurDate, Fcredence, FAccountDate, useUnit, isDefaultDate, isArchive, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        public ActionResult GetStubbsInstocks(Pagination pagination, string FDocuNO, string FHappenComNO, string FContainerNO, string FCurDate, string Fcredence, string FAccountDate, bool isDefaultDate, bool isArchive)
        {
            string FDocuTypeNo = "RI";

            var data = new
            {
                rows = app.GetPurchaseInstocks(pagination, FDocuNO, FHappenComNO, FContainerNO, FCurDate, Fcredence, FAccountDate, useUnit, isDefaultDate, isArchive, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        public ActionResult GetOutstocks(Pagination pagination, string FDocuNO, string FHappenComNO, string FContainerNO, string FCurDate, string Fcredence, string FAccountDate, bool isDefaultDate, bool isArchive)
        {
            string FDocuTypeNo = "RC";

            var data = new
            {
                rows = app.GetPurchaseInstocks(pagination, FDocuNO, FHappenComNO, FContainerNO, FCurDate, Fcredence, FAccountDate, useUnit, isDefaultDate, isArchive, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        public ActionResult GetStubbsOutstocks(Pagination pagination, string FDocuNO, string FHappenComNO, string FContainerNO, string FCurDate, string Fcredence, string FAccountDate, bool isDefaultDate, bool isArchive)
        {
            string FDocuTypeNo = "RO";

            var data = new
            {
                rows = app.GetPurchaseInstocks(pagination, FDocuNO, FHappenComNO, FContainerNO, FCurDate, Fcredence, FAccountDate, useUnit, isDefaultDate, isArchive, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        public ActionResult GetContainerRepair(Pagination pagination, string FDocuNO, string FHappenComNO, string FContainerNO, string FCurDate, string Fcredence, string FAccountDate, bool isDefaultDate, bool isArchive)
        {
            string FDocuTypeNo = "RX";

            var data = new
            {
                rows = app.GetPurchaseInstocks(pagination, FDocuNO, FHappenComNO, FContainerNO, FCurDate, Fcredence, FAccountDate, useUnit, isDefaultDate, isArchive, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        public ActionResult GetContainerScraps(Pagination pagination, string FDocuNO, string FHappenComNO, string FContainerNO, string FCurDate, string Fcredence, string FAccountDate, bool isDefaultDate, bool isArchive)
        {
            string FDocuTypeNo = "RS";

            var data = new
            {
                rows = app.GetPurchaseInstocks(pagination, FDocuNO, FHappenComNO, FContainerNO, FCurDate, Fcredence, FAccountDate, useUnit, isDefaultDate, isArchive, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        public ActionResult GetContainerTakeInventories(Pagination pagination, string FDocuNO, string FHappenComNO, string FContainerNO, string FCurDate, string Fcredence, string FAccountDate, bool isDefaultDate, bool isArchive)
        {
            string FDocuTypeNo = "RP";

            var data = new
            {
                rows = app.GetPurchaseInstocks(pagination, FDocuNO, FHappenComNO, FContainerNO, FCurDate, Fcredence, FAccountDate, useUnit, isDefaultDate, isArchive, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        public ActionResult GetPrintDetailsData(bool isDefaultDate, bool isArchive, string ids)
        {
            var data = app.GetPrintDetailsData(useUnit, curUser, isDefaultDate, isArchive, ids);

            return Content(data.ToJson());
        }


        public ActionResult GetPurchaseInstockAdds(Pagination pagination, string FContainerNO)
        {
            var data = new
            {
                rows = app.GetPurchaseInstockAdds(pagination, FContainerNO, useUnit),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        public ActionResult GetPurchaseOutstockAdds(Pagination pagination, string FContainerNO)
        {
            var data = new
            {
                rows = app.GetPurchaseOutstockAdds(pagination, FContainerNO, useUnit),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        public ActionResult GetPurchaseInstockView(Pagination pagination, string FDocuNO, bool isArchive, bool isDefaultDate)
        {
            string FDocuTypeNo = "RG";

            var data = new
            {
                rows = app.GetPurchaseInstockView(pagination, FDocuNO, useUnit, isArchive, isDefaultDate, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        public ActionResult GetTurnOverInstockView(Pagination pagination, string FDocuNO, bool isArchive, bool isDefaultDate)
        {
            string FDocuTypeNo = "RR";

            var data = new
            {
                rows = app.GetPurchaseInstockView(pagination, FDocuNO, useUnit, isArchive, isDefaultDate, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        public ActionResult GetStubbsInstockView(Pagination pagination, string FDocuNO, bool isArchive, bool isDefaultDate)
        {
            string FDocuTypeNo = "RI";

            var data = new
            {
                rows = app.GetPurchaseInstockView(pagination, FDocuNO, useUnit, isArchive, isDefaultDate, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        public ActionResult GetOutstockView(Pagination pagination, string FDocuNO, bool isArchive, bool isDefaultDate)
        {
            string FDocuTypeNo = "RC";

            var data = new
            {
                rows = app.GetPurchaseInstockView(pagination, FDocuNO, useUnit, isArchive, isDefaultDate, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        public ActionResult GetStubbsOutstockView(Pagination pagination, string FDocuNO, bool isArchive, bool isDefaultDate)
        {
            string FDocuTypeNo = "RO";

            var data = new
            {
                rows = app.GetPurchaseInstockView(pagination, FDocuNO, useUnit, isArchive, isDefaultDate, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        public ActionResult GetContainerRepairView(Pagination pagination, string FDocuNO, bool isArchive, bool isDefaultDate)
        {
            string FDocuTypeNo = "RX";

            var data = new
            {
                rows = app.GetPurchaseInstockView(pagination, FDocuNO, useUnit, isArchive, isDefaultDate, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        public ActionResult GetContainerScrapView(Pagination pagination, string FDocuNO, bool isArchive, bool isDefaultDate)
        {
            string FDocuTypeNo = "RS";

            var data = new
            {
                rows = app.GetPurchaseInstockView(pagination, FDocuNO, useUnit, isArchive, isDefaultDate, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        public ActionResult GetContainerTakeInventoryView(Pagination pagination, string FDocuNO, bool isArchive, bool isDefaultDate)
        {
            string FDocuTypeNo = "RP";

            var data = new
            {
                rows = app.GetPurchaseInstockView(pagination, FDocuNO, useUnit, isArchive, isDefaultDate, FDocuTypeNo),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        public ActionResult GetContainerLedgers(Pagination pagination, string FAccountDate, string FContainerNO, string FContainerTypeNO, bool isDefaultDate)
        {
            var data = new
            {
                rows = app.GetContainerLedgers(pagination, FAccountDate, useUnit, FContainerNO, FContainerTypeNO, isDefaultDate),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };

            return Content(data.ToJson());
        }

        public ActionResult GetContainerLedgerDetails(Pagination pagination, string FAccountDate, string FContainerNO)
        {
            bool isDefaultDate = FAccountDate == app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            var data = new
            {
                rows = app.GetContainerLedgerDetails(pagination, FAccountDate, useUnit, FContainerNO, isDefaultDate),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };

            return Content(data.ToJson());
        }
        public ActionResult GetContainerLedgerStatistics(Pagination pagination, string FAccountDate, string FContainerNO)
        {
            bool isDefaultDate = FAccountDate == app.GetLedgerDate(useUnit, factoryFlag, MYDESC, curUser);

            var data = new
            {
                rows = app.GetContainerLedgerStatistics(pagination, FAccountDate, useUnit, FContainerNO, isDefaultDate),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };

            return Content(data.ToJson());
        }

        public ActionResult GetReceiveAndDispatchStatisticsCate(Pagination pagination, string FAccountDate, string FContainerTypeNO, bool isDefaultDate)
        {
            var data = new
            {
                rows = app.GetReceiveAndDispatchStatisticsCate(pagination, FAccountDate, useUnit, FContainerTypeNO, isDefaultDate),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };

            return Content(data.ToJson());
        }
        public ActionResult GetReceiveAndDispatchStatisticsParts(Pagination pagination, string FAccountDate, string FContainerTypeNO, bool isDefaultDate)
        {
            var data = new
            {
                rows = app.GetReceiveAndDispatchStatisticsParts(pagination, FAccountDate, useUnit, FContainerTypeNO, isDefaultDate),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };

            return Content(data.ToJson());
        }

        public ActionResult UpdateContainerDetails(string postData)
        {

            Dictionary<string, object> param = postData.ToObject<Dictionary<string, object>>();

            param.Add("UseUnit", useUnit);

            param.Add("FCreateBy", curUser);

            param.Add("FFacNum", factoryFlag);

            param.Add("Status", ((int)采购状态.入库新增).ToString());

            param.Add("FDocuID", Guid.NewGuid());

            param.Add("FDocuListID", Guid.NewGuid());

            param.Add("DocumentNumType", "正式");

            var data = app.UpdateContainerDetails(param);

            return Content(data.ToJson());
        }
        public ActionResult UpdateContainerOutDetails(string postData)
        {

            Dictionary<string, object> param = postData.ToObject<Dictionary<string, object>>();

            param.Add("UseUnit", useUnit);

            param.Add("FCreateBy", curUser);

            param.Add("FFacNum", factoryFlag);

            param.Add("Status", ((int)采购状态.出库新增).ToString());

            param.Add("FDocuID", Guid.NewGuid());

            param.Add("FDocuListID", Guid.NewGuid());

            param.Add("DocumentNumType", "正式");

            var data = app.UpdateContainerDetails(param);

            return Content(data.ToJson());
        }

        public ActionResult UpdateContainerRepairDetails(string postData)
        {
            Dictionary<string, object> param = postData.ToObject<Dictionary<string, object>>();

            param.Add("UseUnit", useUnit);

            param.Add("FCreateBy", curUser);

            param.Add("FFacNum", factoryFlag);

            param.Add("Status", ((int)采购状态.返修新增).ToString());

            param.Add("FDocuID", Guid.NewGuid());

            param.Add("FDocuListID", Guid.NewGuid());

            param.Add("DocumentNumType", "正式");

            var data = app.UpdateContainerDetails(param);

            return Content(data.ToJson());
        }
        public ActionResult UpdateContainerScrapDetails(string postData)
        {
            Dictionary<string, object> param = postData.ToObject<Dictionary<string, object>>();

            param.Add("UseUnit", useUnit);

            param.Add("FCreateBy", curUser);

            param.Add("FFacNum", factoryFlag);

            param.Add("Status", ((int)采购状态.报废新增).ToString());

            param.Add("FDocuID", Guid.NewGuid());

            param.Add("FDocuListID", Guid.NewGuid());

            param.Add("DocumentNumType", "正式");

            var data = app.UpdateContainerDetails(param);

            return Content(data.ToJson());
        }
        public ActionResult UpdateContainerTakeInventoryDetails(string postData)
        {
            Dictionary<string, object> param = postData.ToObject<Dictionary<string, object>>();

            param.Add("UseUnit", useUnit);

            param.Add("FCreateBy", curUser);

            param.Add("FFacNum", factoryFlag);

            param.Add("Status", ((int)采购状态.盘存新增).ToString());

            param.Add("FDocuID", Guid.NewGuid());

            param.Add("FDocuListID", Guid.NewGuid());

            param.Add("DocumentNumType", "正式");

            var data = app.UpdateContainerDetails(param);

            return Content(data.ToJson());
        }
        public ActionResult DeletePurchaseInstocks(string postDataList)
        {

            List<Dictionary<string, object>> paramList = postDataList.ToList<Dictionary<string, object>>();

            foreach (Dictionary<string, object> param in paramList)
            {
                param.Add("UseUnit", useUnit);

                param.Add("FFacNum", factoryFlag);

                param.Add("FDescription2", string.Empty);

                param.Add("FDouBarCode", string.Empty);

                param.Add("FDocuTypeNO", param["FDocuTypeNo"]);

                param.Add("FItemDesc", param["FDocuTypeName"]);

                param.Add("Status", ((int)采购状态.入库删除).ToString());

                param.Add("DocumentNumType", "正式");
            }


            var data = app.BatchExcutePurchaseInstocks(paramList);

            return Content(data.ToJson());
        }

        public ActionResult DeleteOutstocks(string postDataList)
        {

            List<Dictionary<string, object>> paramList = postDataList.ToList<Dictionary<string, object>>();

            foreach (Dictionary<string, object> param in paramList)
            {
                param.Add("UseUnit", useUnit);

                param.Add("FFacNum", factoryFlag);

                param.Add("FDescription2", string.Empty);

                param.Add("FDouBarCode", string.Empty);

                param.Add("FDocuTypeNO", param["FDocuTypeNo"]);

                param.Add("FItemDesc", param["FDocuTypeName"]);

                param.Add("Status", ((int)采购状态.出库删除).ToString());

                param.Add("DocumentNumType", "正式");
            }


            var data = app.BatchExcutePurchaseInstocks(paramList);

            return Content(data.ToJson());
        }

        public ActionResult DeleteContainerRepair(string postDataList)
        {

            List<Dictionary<string, object>> paramList = postDataList.ToList<Dictionary<string, object>>();

            foreach (Dictionary<string, object> param in paramList)
            {
                param.Add("UseUnit", useUnit);

                param.Add("FFacNum", factoryFlag);

                param.Add("FDescription2", string.Empty);

                param.Add("FDouBarCode", string.Empty);

                param.Add("FDocuTypeNO", param["FDocuTypeNo"]);

                param.Add("FItemDesc", param["FDocuTypeName"]);

                param.Add("Status", ((int)采购状态.返修删除).ToString());

                param.Add("DocumentNumType", "正式");
            }


            var data = app.BatchExcutePurchaseInstocks(paramList);

            return Content(data.ToJson());
        }
        public ActionResult DeleteContainerScrap(string postDataList)
        {

            List<Dictionary<string, object>> paramList = postDataList.ToList<Dictionary<string, object>>();

            foreach (Dictionary<string, object> param in paramList)
            {
                param.Add("UseUnit", useUnit);

                param.Add("FFacNum", factoryFlag);

                param.Add("FDescription2", string.Empty);

                param.Add("FDouBarCode", string.Empty);

                param.Add("FDocuTypeNO", param["FDocuTypeNo"]);

                param.Add("FItemDesc", param["FDocuTypeName"]);

                param.Add("Status", ((int)采购状态.报废删除).ToString());

                param.Add("DocumentNumType", "正式");
            }

            var data = app.BatchExcutePurchaseInstocks(paramList);

            return Content(data.ToJson());
        }
        public ActionResult DeleteContainerTakeInventory(string postDataList)
        {
            List<Dictionary<string, object>> paramList = postDataList.ToList<Dictionary<string, object>>();

            foreach (Dictionary<string, object> param in paramList)
            {
                param.Add("UseUnit", useUnit);

                param.Add("FFacNum", factoryFlag);

                param.Add("FDescription2", string.Empty);

                param.Add("FDouBarCode", string.Empty);

                param.Add("FDocuTypeNO", param["FDocuTypeNo"]);

                param.Add("FItemDesc", param["FDocuTypeName"]);

                param.Add("Status", ((int)采购状态.盘存删除).ToString());

                param.Add("DocumentNumType", "正式");
            }

            var data = app.BatchExcutePurchaseInstocks(paramList);

            return Content(data.ToJson());
        }
        public ActionResult AduitContainer(string postDataList)
        {
            List<Dictionary<string, object>> paramList = postDataList.ToList<Dictionary<string, object>>();

            foreach (Dictionary<string, object> param in paramList)
            {
                param.Add("UseUnit", useUnit);
            }

            var data = app.BatchExcuteAuditContainer(paramList);

            return Content(data.ToJson());
        }


        public ActionResult UpdatePurchaseInstock(string postData)
        {
            Dictionary<string, object> param = postData.ToObject<Dictionary<string, object>>();

            param.Add("UseUnit", useUnit);

            param.Add("FFacNum", factoryFlag);

            param.Add("FDescription2", string.Empty);

            param.Add("FDouBarCode", string.Empty);

            param.Add("FDocuTypeNO", param["FDocuTypeNo"]);

            param.Add("FItemDesc", param["FDocuTypeName"]);

            param.Add("Status", ((int)采购状态.入库修改).ToString());

            param.Add("DocumentNumType", "正式");

            var data = app.ExcutePurchaseInstock(param);

            return Content(data.ToJson());
        }

        public ActionResult UpdateOutstock(string postData)
        {
            Dictionary<string, object> param = postData.ToObject<Dictionary<string, object>>();

            param.Add("UseUnit", useUnit);

            param.Add("FFacNum", factoryFlag);

            param.Add("FDescription2", string.Empty);

            param.Add("FDouBarCode", string.Empty);

            param.Add("FDocuTypeNO", param["FDocuTypeNo"]);

            param.Add("FItemDesc", param["FDocuTypeName"]);

            param.Add("Status", ((int)采购状态.出库修改).ToString());

            param.Add("DocumentNumType", "正式");

            var data = app.ExcutePurchaseInstock(param);

            return Content(data.ToJson());
        }

        public ActionResult UpdateContainerRepair(string postData)
        {
            Dictionary<string, object> param = postData.ToObject<Dictionary<string, object>>();

            param.Add("UseUnit", useUnit);

            param.Add("FFacNum", factoryFlag);

            param.Add("FDescription2", string.Empty);

            param.Add("FDouBarCode", string.Empty);

            param.Add("FDocuTypeNO", param["FDocuTypeNo"]);

            param.Add("FItemDesc", param["FDocuTypeName"]);

            param.Add("Status", ((int)采购状态.返修修改).ToString());

            param.Add("DocumentNumType", "正式");

            var data = app.ExcutePurchaseInstock(param);

            return Content(data.ToJson());
        }

        public ActionResult UpdateContainerScrap(string postData)
        {
            Dictionary<string, object> param = postData.ToObject<Dictionary<string, object>>();

            param.Add("UseUnit", useUnit);

            param.Add("FFacNum", factoryFlag);

            param.Add("FDescription2", string.Empty);

            param.Add("FDouBarCode", string.Empty);

            param.Add("FDocuTypeNO", param["FDocuTypeNo"]);

            param.Add("FItemDesc", param["FDocuTypeName"]);

            param.Add("Status", ((int)采购状态.报废修改).ToString());

            param.Add("DocumentNumType", "正式");

            var data = app.ExcutePurchaseInstock(param);

            return Content(data.ToJson());
        }

        public ActionResult UpdateContainerTakeInventory(string postData)
        {
            Dictionary<string, object> param = postData.ToObject<Dictionary<string, object>>();

            param.Add("UseUnit", useUnit);

            param.Add("FFacNum", factoryFlag);

            param.Add("FDescription2", string.Empty);

            param.Add("FDouBarCode", string.Empty);

            param.Add("FDocuTypeNO", param["FDocuTypeNo"]);

            param.Add("FItemDesc", param["FDocuTypeName"]);

            param.Add("Status", ((int)采购状态.报废修改).ToString());

            param.Add("DocumentNumType", "正式");

            var data = app.ExcutePurchaseInstock(param);

            return Content(data.ToJson());
        }

        public ActionResult CalcStoProStockCataSum(string date, bool isCurrent)
        {
            string useunit = Configs.GetValue("UseUnit");

            string userName = OperatorProvider.Provider.GetCurrent().UserName;
            //exec  RQK_33_BB_StoProStockCata_RB_SUM  '使用单位','操作人员','选择的台账日期','状态' （选择日期台账等于当前台账日期 为0，选择日期台账不等于当前台账日期 为1）
            var result = app.CalcStoProStockCataSum(date, isCurrent, useunit, userName);

            return Content(result.ToJson());
        }

    }
}
